// import {dispatch} from 'redux'
import {LOGIN,LOGOUT} from '../actionType'
import {getLogin} from '@/api/login'
import { setToken, removeToken } from '@/utils/storage'
export const login =(data)=>{
   return async dispatch=>{
        const res = await getLogin(data)
        setToken('Bearer ' + res.data.token)
        dispatch({
            type:LOGIN,
            payload:res.data.token
        })

    }
}
export const logout = dispatch=>{
    removeToken()
    dispatch({
        type:LOGOUT,
    })
}